#pragma once

#include <string>

#include <d3d9.h>
#include <d3dx9tex.h>

class DxManager
{
public:

	static DxManager &getInstance(){static DxManager pInstance;return pInstance;}

	DxManager(void);
	~DxManager(void);

	bool initDirect3D(HWND hwnd);
	void beginRender(void);
	void endRender(void);
	void shutdown(void);

	LPDIRECT3DDEVICE9 getDevice(void);

	IDirect3DSurface9* getSurfaceFromBitmap(std::string filename);
	
	IDirect3DSurface9* getBackBuffer(void);
	void blitToSurface(IDirect3DSurface9* srcSurface, const RECT *srcRect, const RECT *destRect);
	

	void createCamera(float nearClip, float farClip);
	void moveCamera(D3DXVECTOR3 vec);
	void pointCamera(D3DXVECTOR3 vec);

private:


	LPDIRECT3D9             pD3D;                                              
	LPDIRECT3DDEVICE9       pd3dDevice;

	D3DXMATRIX				matView;
	D3DXMATRIX				matProj;
	D3DXVECTOR3				cameraPosition;			// the position of the camera
	D3DXVECTOR3				cameraLook;				// where the camera is pointing

};
